﻿using Leikjavefurinn.Repo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Leikjavefurinn.Controllers
{
	public class HomeController : Controller
	{
		private ITicTacToeRepo _repository = null;

		public HomeController()
		{
			_repository = new TicTacToeRepo();
		}

		public HomeController(ITicTacToeRepo rep)
		{
			_repository = rep;
		}

		//Fall sem skilar lista af öllum Active Tic Tac Toe leikjum í Index-ið
        // --- Afhverju viljum við allt þetta TTT dót í HomeController í staðin fyrir TTTController?
		public ActionResult Index()
		{
			 IEnumerable<Leikjavefurinn.TicTacToe> Games = (from tick in _repository.AllTickTacToe()
															join game in _repository.AllGames()
															on tick.GameId equals game.GameId
															where game.IsActive == true
															select tick);
			return View(Games);
		}

		public ActionResult About()
		{
			ViewBag.Message = "Your app description page.";

			return View();
		}

		public ActionResult Contact()
		{
			ViewBag.Message = "Your contact page.";

			return View();
		}

        public ActionResult CreateTicTac()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

		public ActionResult PlayTicTac()
		{
			ViewBag.Message = "Your contact page.";

			return View();
		}

		public ActionResult Chat()
		{
			return View();
		}
	}
}
